package cn.sccl.dirms.topo.discovery.model;

import cn.sccl.dirms.topo.discovery.util.Constants;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

public class DeviceBaseInfo implements Serializable {
    /**
     * 从完整信息只复制基础信息
     *
     * @param deviceInfo
     */
    public DeviceBaseInfo(DeviceInfo deviceInfo) {
        this.deviceIP = deviceInfo.getDeviceIP();
        this.deviceMAC = deviceInfo.getDeviceMAC();
        this.deviceName = deviceInfo.getDeviceName();
        this.deviceProtocol = deviceInfo.getDeviceProtocol();
        this.deviceType = deviceInfo.getDeviceType();
        this.zabbixId = deviceInfo.getZabbixId();
        this.nodeId = deviceInfo.getNodeId();
        this.deviceMacs = deviceInfo.getDeviceMacs();
        this.deviceIps = deviceInfo.getDeviceIps();
        this.sysDesc = deviceInfo.getSystemInfo().sysDesc;
        this.sysObjectID = deviceInfo.getSystemInfo().sysObjectID;
        this.sysUptime = deviceInfo.getSystemInfo().sysUptime;
        this.sysContact = deviceInfo.getSystemInfo().sysContact;
        this.sysName = deviceInfo.getSystemInfo().sysName;
        this.sysLocation = deviceInfo.getSystemInfo().sysLocation;
        this.sysService = deviceInfo.getSystemInfo().sysService;
    }

    private static final long serialVersionUID = 1290738801758977389L;
    private String deviceIP = "";  //IP地址
    private String deviceMAC = ""; //MAC地址
    private String deviceProtocol = ""; //发现协议
    private String deviceName = ""; //名称
    private String deviceType = Constants.DeviceTypeUnkown;// 类型
    private String zabbixId;//在zabbix系统中的hostid
    private String nodeId;//在资源表t_int_nodes中的nodeId
    private Set<String> deviceMacs = new HashSet<String>();//MAC地址列表
    private Set<String> deviceIps = new HashSet<String>();//IP地址列表
    private String sysDesc;
    private String sysObjectID;
    private String sysUptime;
    private String sysContact;
    private String sysName;
    private String sysLocation;
    private String sysService;

    @Override
    public String toString() {
        return "deviceIP:" + deviceIP + ";deviceMAC:" + deviceMAC + ";deviceType:" + deviceType + " ";
    }


    public Set<String> getDeviceMacs() {
        return deviceMacs;
    }

    public void setDeviceMacs(Set<String> deviceMacs) {
        this.deviceMacs = deviceMacs;
    }

    public Set<String> getDeviceIps() {
        return deviceIps;
    }

    public void setDeviceIps(Set<String> deviceIps) {
        this.deviceIps = deviceIps;
    }

    public String getSysDesc() {
        return sysDesc;
    }

    public void setSysDesc(String sysDesc) {
        this.sysDesc = sysDesc;
    }

    public String getSysObjectID() {
        return sysObjectID;
    }

    public void setSysObjectID(String sysObjectID) {
        this.sysObjectID = sysObjectID;
    }

    public String getSysUptime() {
        return sysUptime;
    }

    public void setSysUptime(String sysUptime) {
        this.sysUptime = sysUptime;
    }

    public String getSysContact() {
        return sysContact;
    }

    public void setSysContact(String sysContact) {
        this.sysContact = sysContact;
    }

    public String getSysName() {
        return sysName;
    }

    public void setSysName(String sysName) {
        this.sysName = sysName;
    }

    public String getSysLocation() {
        return sysLocation;
    }

    public void setSysLocation(String sysLocation) {
        this.sysLocation = sysLocation;
    }

    public String getSysService() {
        return sysService;
    }

    public void setSysService(String sysService) {
        this.sysService = sysService;
    }

    public String getDeviceIP() {
        return deviceIP;
    }

    public void setDeviceIP(String deviceIP) {
        this.deviceIP = deviceIP;
    }

    public String getDeviceMAC() {
        return deviceMAC;
    }

    public void setDeviceMAC(String deviceMAC) {
        this.deviceMAC = deviceMAC;
    }

    public String getDeviceProtocol() {
        return deviceProtocol;
    }

    public void setDeviceProtocol(String deviceProtocol) {
        this.deviceProtocol = deviceProtocol;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }

    public String getZabbixId() {
        return zabbixId;
    }

    public void setZabbixId(String zabbixId) {
        this.zabbixId = zabbixId;
    }

    public String getNodeId() {
        return nodeId;
    }

    public void setNodeId(String nodeId) {
        this.nodeId = nodeId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DeviceBaseInfo that = (DeviceBaseInfo) o;
        return Objects.equals(deviceIP, that.deviceIP) &&
                Objects.equals(deviceMAC, that.deviceMAC);
    }

    @Override
    public int hashCode() {
        return Objects.hash(deviceIP, deviceMAC, deviceProtocol, deviceName);
    }

    public String getMark() {
        return this.getDeviceMAC() + "-" + this.getDeviceIP();
    }
}